package com.ruitu.mall_98_seller.mvp.model;

import com.ruitu.arad.api.BaseResult;
import com.ruitu.arad.api.PageModel;
import com.ruitu.arad.api.RxUtil;
import com.ruitu.arad.base.BaseModel;
import com.ruitu.mall_98_seller.dao.bean.Msg;
import com.ruitu.mall_98_seller.dao.http.APIRetrofit;
import com.ruitu.router_module.bean.RongToken;
import com.ruitu.router_module.bean.RongUser;

import io.reactivex.Observable;

public class MsgModel {

    // 消息列表
    public static class MsgListM extends BaseModel {

        public Observable<BaseResult<PageModel<Msg>>> reqMsgList(String comId, int size, int page) {
            return APIRetrofit.getDefault().reqMsgList(comId, size, page)
                    .compose(RxUtil.<BaseResult<PageModel<Msg>>>subIoObMain());
        }

        public Observable<BaseResult> reqAllReadMsg(String comId) {
            return APIRetrofit.getDefault().reqAllReadMsg(comId)
                    .compose(RxUtil.<BaseResult>subIoObMain());
        }
    }

    // 消息详情
    public static class MsgDetailM extends BaseModel {

        public Observable<BaseResult<Msg>> reqMsgDetail(String msgId) {
            return APIRetrofit.getDefault().reqMsgDetail(msgId)
                    .compose(RxUtil.<BaseResult<Msg>>subIoObMain());
        }
    }

    // 消息fragment
    public static class MsgFragM extends BaseModel {

        public Observable<BaseResult<String>> reqUnReadMsgNum(String comId) {
            return APIRetrofit.getDefault().reqUnReadMsgNum(comId)
                    .compose(RxUtil.<BaseResult<String>>subIoObMain());
        }

        public Observable<RongToken> reqRongToken(String appKey, String nonce, String timeStamp
                , String signiture, String userId, String userName, String portraitUri) {
            return APIRetrofit.getRongApi().reqRongToken
                    (appKey, nonce, timeStamp, signiture, userId, userName, portraitUri)
                    .compose(RxUtil.<RongToken>subIoObMain());
        }

        public Observable<BaseResult<RongUser>> reqUserInfo(String uId) {
            return APIRetrofit.getDefault().reqUserInfo(uId)
                    .compose(RxUtil.<BaseResult<RongUser>>subIoObMain());
        }
    }
}
